package com.cmbchina.config;

import com.cmbchina.service.ExchangeRateAdapter;
import com.cmbchina.service.IExchangeRateService;
import com.cmbchina.service.SinaExchangeRateService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ExchangeRateServiceConfig {

    @Bean
    public IExchangeRateService getExchangeRateService(){
        //1、根据具体需求，创建不同的汇率服务（sina/sohu）获取汇率
        return new SinaExchangeRateService();
    }

    @Bean
    public ExchangeRateAdapter getExchangeRateAdapter(IExchangeRateService exchangeRateService){
        //2、创建适配器，并配置汇率服务
        return new ExchangeRateAdapter(exchangeRateService);
    }

}
